from flask import Flask, render_template, request, jsonify
from utils.zhipu_ai import get_zhipu_response  # 导入函数

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/chat', methods=['POST'])
def chat():
    user_input = request.json.get('user_input')
    response = get_zhipu_response(user_input)  # 调用函数获取响应
    return jsonify({'response': response.content})  # 返回响应内容

if __name__ == '__main__':
    app.run(debug=True)